﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using Assessment.DBUtility;
using System.Data.SqlClient;

namespace Assessment.DAL
{
    public class DBUtility
    {
        /// <summary>
        /// 分页获取数据列表
        /// </summary>
        /// <param name="TableName"></param>
        /// <param name="StrGetFields"></param>
        /// <param name="OrderField"></param>
        /// <param name="StrWhere"></param>
        /// <param name="PageSize"></param>
        /// <param name="PageIndex"></param>
        /// <param name="OrderType"></param>
        /// <param name="RecordCount"></param>
        /// <returns></returns>
        public DataSet GetListByPage(string TableName, string StrGetFields, string OrderField, string StrWhere, int PageSize, int PageIndex, int OrderType)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("EXEC Proc_Table_Paging @TableName,@StrGetFields,@OrderField,@PageSize,@PageIndex,@OrderType,@StrWhere,@doCount");

            SqlParameter[] paras = new SqlParameter[]{
                new SqlParameter("@TableName",TableName),
                new SqlParameter("@StrGetFields",StrGetFields),
                new SqlParameter("@OrderField",OrderField),
                new SqlParameter("@StrWhere",StrWhere),
                new SqlParameter("@PageSize",PageSize),
                new SqlParameter("@PageIndex",PageIndex),
                new SqlParameter("@OrderType",OrderType),
                new SqlParameter("@doCount",1)
            };

            return DbHelperSQL.Query(strSql.ToString(), paras);
        }
    }
}
